/**
 * creater:kunjiang.zhou@dhc.com.cn
 * create time:2017-05-31 20:32:22
 * describe:二次入库
 */
APP.controller('InputSecondController', ['$scope', 'InputSecondService','PopupService','OnlineService',
    function ($scope, InputSecondService,PopupService,OnlineService) {

        /***变量声明***/
        $scope.secondData = {
            barcode: ''
        };
        $scope.ifData = false;
        $scope.dataList = '';//存放多条信息

        /**
         * 初始化函数
         */
        $scope.$on('$ionicView.beforeEnter', function () {
            $scope.init();
        });
        $scope.init = function () {
            $scope.ifData = false;
        };

        /**
         * 按条码查询物料信息
         */
        $scope.getByCode = function () {
            OnlineService.getByCode($scope.secondData.barCode)
                .then(function (response) {
                    console.log('成功回调方法', response);
                    if (response.data.data.state == '暂存区') {//查询状态
                        $scope.dataList = response.data.data;
                        if($scope.dataList){
                            $scope.ifData = true;
                        } else {
                            PopupService.showToast('请输入正确条码');
                        }
                        console.log('$scope.onlineData', $scope.onlineData);
                    } else {
                        PopupService.showToast(response.data.data.state);
                    }
                }, function (response) {
                    console.log('失败回调方法', response)
                })
        };

        $scope.cancel = function () {
            $scope.ifData = false;
        }


    }
]);

/**
 * creater:kunjiang.zhou@dhc.com.cn
 * create time:2017-05-31 20:32:22
 * describe:二次入库
 */
APP.service('InputSecondService', ['$http', 'UrlService', function ($http, UrlService) {
    /**
     * 登录方法
     * @param username  登录用户名
     * @param password  登录密码
     */
    this.doLogin = function (username, password) {
        var param = {
            username: username,
            password: password
        };
        return $http.post(UrlService.getUrl('LOGIN'), param);
    }

}]);
